package io.renren.modules.aic.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import io.renren.modules.aic.entity.MachineGiveEntity;
import io.renren.modules.aic.service.MachineGiveService;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 矿机赠送表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-03-30 15:44:17
 */
@RestController
@RequestMapping("aic/machinegive")
public class MachineGiveController {
	@Autowired
	private MachineGiveService machineGiveService;

	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("aic:machinegive:list")
	public R list(@RequestParam Map<String, Object> params) {
		PageUtils page = machineGiveService.queryPage(params);

		return R.ok().put("page", page);
	}

	/**
	 * 保存
	 */
	@SysLog("发放矿机")
	@RequestMapping("/save")
	@RequiresPermissions("aic:machinegive:save")
	public R save(@RequestBody MachineGiveEntity machineGive) {
		// 校验类型
		ValidatorUtils.validateEntity(machineGive);
		machineGiveService.save(machineGive);

		return R.ok();
	}
}
